﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package net.wooga.pets.controllers.world {
    import flash.events.*;
    import net.wooga.pets.events.*;
    import net.wooga.pets.controllers.data.*;
    import net.wooga.pets.models.*;
    import net.wooga.pets.constants.*;
    import org.robotlegs.mvcs.*;
    import net.wooga.pets.models.world.*;

    public class ShowPatientPoolCommand extends Command {

        public var event:InfoEvent;
        public var worldModel:WorldModel;
        public var computerModel:ComputerModel;
        public var userModel:UserModel;

        public static var SECOND_TUTORIAL_PET:String = "Sheep";

        override public function execute():void{
            var _local4:PatientPoolVO;
            var _local6:Object;
            var _local7:Array;
            var _local8:Boolean;
            var _local9:Object;
            var _local10:String;
            l(("c execute: " + this.execute));
            var _local1:Array = this.computerModel.matrix;
            var _local2:Array = [];
            var _local3:Array = [];
            var _local5 = 1;
            for each (_local6 in _local1) {
                _local4 = new PatientPoolVO(_local6);
                new PatientPoolVO(_local6).hasMinLevel = (((_local4.petType == SECOND_TUTORIAL_PET)) || ((_local4.minLevel <= this.userModel.level)));
                _local4.diseaseId = _local5;
                for each (_local10 in _local4.treatments) {
                    if (((!(this.worldModel.hasAreaType(_local10))) && (!((_local4.petType == SECOND_TUTORIAL_PET))))){
                        _local4.addMissingRoomType(_local10);
                    };
                };
                if (_local4.hasMinLevel){
                    _local2.push(_local4);
                } else {
                    _local3.push(_local4);
                };
                _local5++;
            };
            _local2.sortOn("duration", Array.NUMERIC);
            _local3.sortOn("minLevel", Array.NUMERIC);
            _local7 = _local2.concat(_local3);
            _local8 = (this.worldModel.patients.length < (this.worldModel.doctors.length + 7));
            _local9 = {pets:_local7, areMorePetsAllowed:_local8};
            dispatch(new InfoEvent(EventConstants.SHOW_COMPUTER_DISPLAY, null, _local9));
            dispatch(new Event(EventConstants.HANDLE_NEXT_AVATAR_ACTION));
        }

    }
}//package net.wooga.pets.controllers.world 
